package cn.dylan.system.controller;

import cn.dylan.basic.annotation.PreAuthorize;
import cn.dylan.basic.domain.Permission;
import cn.dylan.basic.util.PageList;
import cn.dylan.system.query.PermissionQuery;
import cn.dylan.system.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/permission")
public class PermissionController {

    @Autowired
    private IPermissionService permissionService;

    @PostMapping
    @PreAuthorize(name = "分页获取权限", sn = "permission:post")
    public PageList<Permission> handlerQueryPage(@RequestBody PermissionQuery query){
        try {
            return permissionService.queryPage(query);
        } catch (Exception e) {
            return new PageList<>();
        }
    }


}
